package net.begincode.handler;

import net.begincode.model.User;
import net.begincode.service.UserService;
import org.springframework.stereotype.Component;

/**
 * Created by saber on 2017/9/22.
 */
@Component
public class UserHandler {

    private UserService userService;

    /**
     * 用户登陆判断
     *
     * @param mail
     * @param password
     * @return 存在true  不存在 false
     */
    public boolean login(String mail , String password){
        User user = userService.getByMail(mail);
        return user != null && password.equals(user.getUserPassword());
    }

    /**
     * 判断用户登陆标识
     *
     * @param mail
     * @param accesstoken
     * @return 存在true  不存在 false
     */
    public boolean loginAccesstoken(String mail , String accesstoken){
        User user = userService.getByMail(mail);
        return user != null && accesstoken.equals(user.getUserPassword());
    }
}
